package com.frinder.official.akka.dispatcher;

import com.frinder.official.spring.MyBaseActor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * Created by frinder on 2017/9/28.
 * <p>
 * simulation blocking operation
 */
@Component
@Scope("prototype")
public class BlockingActor extends MyBaseActor {

    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(Integer.class, i -> {
                    Thread.sleep(5000); //block for 5 seconds, representing blocking I/O, etc
                    System.out.println("Blocking operation finished: " + i);
                })
                .build();
    }

}
